<div class="p-head">
    <b class="c3"><?= $bill_title ?></b>
    <div class="r">
        <a href="/bbs/index/3/" class="ajax" title="意见反馈">意见反馈</a>
    </div>
    <div id="desc">
        <?= isset($familyinfo['name']) ? $familyinfo['name'] . ($familyinfo['desc'] ? " - " . $familyinfo['desc'] : '') : '记录每天生活的点点滴滴。。。' ?>
    </div>
</div>
<div class="tabs_t tabs_n">
    <ul class="ajax" id="billul">
        <?php foreach (get_bill_type() as $m => $n) { ?>
            <li class="<?= $m == $type ? 'current' : '' ?>" rel="<?= $m ?>"><a href="/bill/index/<?= $m ?>/?user_id=<?= $user_id ?>"><?= $n ?></a></li>
        <?php } ?>
    </ul>
    <span class="r dropdown clear">
        <a href="/bill/add/<?= segment(2) ?>/" title="新增记账" id="bill_add" class="btn btn_s dialog" callback="bill_callback">
            <span><b class="icon icon-edit"></b><em>新增记账</em></span>
        </a>
        <ul class="downlist">
            <li><a href="/bill/add/" id="bill_add" title="批量记账" class="dialog" callback="bill_callback"><b class="icon icon-gray icon-pencil"></b>普通记账</a></li>
            <!--            <li><a href="/bill/tiny/" title="快速记账" class="dialog"><b class="icon icon-gray icon-pencil"></b>快速记账</a></li>-->
            <li><a href="/bill/multi/" title="批量记账" class="dialog" callback="bill_multi_callback"><b class="icon icon-gray icon-th-list"></b>批量记账</a></li>
        </ul>
    </span>
</div>
<div id="bill">
    <table class="data list" cellpadding="0" cellspacing="1" width="100%" style="margin-bottom:0;margin-top:3px;">
        <thead class="thead">
        <form action="" class="billform">
            <input type="hidden" name="user_id" id="user_id" value="<?= $user_id ?>" />
            <input type="hidden" name="orderby" id="orderby" />
            <input type="hidden" name="limitdate" id="limitdate" />
            <input type="hidden" name="limitamount" id="limitamount" />
            <input type="hidden" name="limitoutstanding" id="limitoutstanding" />
            <tr style="background:#f3f3f3;">
                <th width="95">
                    <span class="dropdown clear">
                        <a href="javascript:;" title="点击可按日期排序" class="btn btn_n_s orderby">
                            <span><em>日期<i field="0" rel="0"></i></em><b class="arrow"></b></span>
                        </a>
                        <ul class="filter datefilter" field="limitdate">
                            <li><a href="javascript:;" rel="0">全部</a></li>              
                            <li><a href="javascript:;" rel="1">今天</a> / <a href="javascript:;" rel="2">昨天</a></li>              
                            <li><a href="javascript:;" rel="3">本周</a> / <a href="javascript:;" rel="4">上周</a></li>                  
                            <li><a href="javascript:;" rel="5">本月</a> / <a href="javascript:;" rel="6">上月</a></li>                  
                            <li><a href="javascript:;" rel="7">今年</a> / <a href="javascript:;" rel="8">去年</a></li>              
                            <li class="clear" style="height:90px"><a href="javascript:;">筛选日期</a><br />
                                <span><input type="text" name="startdate" placeholder="开始日期" id="startdate" class="input datepicker" /></span>
                                <span><input type="text" name="enddate" placeholder="结束日期" id="enddate" class="input datepicker" /></span>
                            </li>              
                        </ul>
                    </span>
                </th>
                <?php if ($type != 'transfer' && $type != 'credit') { ?>
                    <th width="100">
                        <span class="dropdown clear">
                            <a href="javascript:;" title="" class="btn btn_n_s">
                                <span><em>类别</em><b class="arrow"></b></span>
                            </a>
                            <ul class="tm filter categoryfilter" style="max-height:370px;overflow-y:auto">
                                <input type="hidden" name="category_id[]" id="cf-1" checked value="-1" /> 
                                <li><input type="checkbox" name="category_id[]" id="cf0" checked value="0" /> <label for="cf0">全部</label><ins title="全部展开"></ins></li>
                                <?php foreach (get_category_list_full($type, true) as $m => $n) { ?>
                                    <li><input type="checkbox" name="category_id[]" id="cf<?= $n['id'] ?>" checked value="<?= $n['id'] ?>" /> 
                                        <label for="cf<?= $n['id'] ?>"><?= cutstr($n['name'], 10, '') ?></label>
                                        <?php if ($n['sons']) { ?>
                                            <ins></ins>
                                        <?php } ?>
                                    </li>
                                    <ul>
                                        <?php foreach ($n['sons'] as $u => $v) { ?>
                                            <li><input type="checkbox" name="category_id[]" id="cf<?= $v['id'] ?>" checked value="<?= $v['id'] ?>" /> 
                                                <label for="cf<?= $v['id'] ?>"> &nbsp;&nbsp;&nbsp;&nbsp;<?= cutstr($v['name'], 8, '') ?></label></li>
                                        <?php } ?>
                                    </ul>
                                <?php } ?>
                            </ul>
                        </span>
                    </th>
                <?php } ?>
                <th width="100">
                    <span class="dropdown clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em><?= $type == 'transfer' ? '转出' : '帐户' ?></em><b class="arrow"></b></span>
                        </a>
                        <ul class="filter accountfilter">
                            <input type="hidden" name="account_id[]" id="af-1" checked value="-1" /> 
                            <?php foreach (get_account_list(null, array(array('id' => 0, 'name' => '全部'))) as $m => $n) { ?>
                                <li><input type="checkbox" name="account_id[]" id="af<?= $n['id'] ?>" checked value="<?= $n['id'] ?>" /> <label for="af<?= $n['id'] ?>"><?= $n['name'] ?></label></li>
                            <?php } ?>
                        </ul>
                    </span>
                </th>
                <?php if ($type == 'transfer') { ?>
                    <th width="100">
                        <span class="dropdown clear">
                            <a href="javascript:;" title="" class="btn btn_n_s">
                                <span><em>转入</em><b class="arrow"></b></span>
                            </a>
                            <ul class="filter inaccountfilter">
                                <input type="hidden" name="inaccount_id[]" id="iaf-1" checked value="-1" /> 
                                <?php foreach (get_account_list(null, array(array('id' => 0, 'name' => '全部'))) as $m => $n) { ?>
                                    <li><input type="checkbox" name="inaccount_id[]" id="iaf<?= $n['id'] ?>" checked value="<?= $n['id'] ?>" /> <label for="iaf<?= $n['id'] ?>"><?= $n['name'] ?></label></li>
                                <?php } ?>
                            </ul>
                        </span>
                    </th>
                <?php } else if ($type == 'credit') { ?>
                    <th width="100">
                        <span class="dropdown clear">
                            <a href="javascript:;" title="" class="btn btn_n_s">
                                <span><em>信用卡</em><b class="arrow"></b></span>
                            </a>
                            <ul class="filter creditfilter">
                                <input type="hidden" name="inaccount_id[]" id="crf-1" checked value="-1" /> 
                                <?php foreach (get_account_list('credit', array(array('id' => 0, 'name' => '全部'))) as $m => $n) { ?>
                                    <li><input type="checkbox" name="inaccount_id[]" id="crf<?= $n['id'] ?>" checked value="<?= $n['id'] ?>" /> <label for="crf<?= $n['id'] ?>"><?= $n['name'] ?></label></li>
                                <?php } ?>
                            </ul>
                        </span>
                    </th>
                <?php } ?>
                <th width="90">
                    <span class="dropdown clear">
                        <a href="javascript:;" title="点击可按金额进行排序" class="btn btn_n_s orderby">
                            <span><em>金额<i field="1" rel="0"></i></em><b class="arrow"></b></span>
                        </a>
                        <ul class="filter amountfilter clear" field="limitamount">
                            <li><a href="javascript:;" rel="0">全部</a></li>
                            <li><a href="javascript:;" rel="1">0~10</a></li>
                            <li><a href="javascript:;" rel="2">11~100</a></li>
                            <li><a href="javascript:;" rel="3">101~1000</a></li>
                            <li><a href="javascript:;" rel="4">1001~10000</a></li>
                            <li><a href="javascript:;" rel="5">10001~100000+</a></li>
                            <li class="clear" style="height:60px">
                                <a href="javascript:;">筛选金额</a><br />
                                <input type="text" class="input" name="startamount" placeholder="最小" size="3"/>-
                                <input type="text" class="input" name="endamount" placeholder="最大" size="3"/></li>
                        </ul>
                    </span>
                </th>
                <?php if ($type == 'borrow') { ?>
                    <th width="90">
                        <span class="dropdown clear">
                            <a href="javascript:;" title="点击可按未结清金额进行排序" class="btn btn_n_s orderby">
                                <span><em>未结清<i field="2" rel="0"></i></em><b class="arrow"></b></span>
                            </a>
                            <ul class="filter amountfilter clear" field="limitoutstanding">
                                <li><a href="javascript:;" rel="0">全部</a></li>
                                <li><a href="javascript:;" rel="1">0~10</a></li>
                                <li><a href="javascript:;" rel="2">11~100</a></li>
                                <li><a href="javascript:;" rel="3">101~1000</a></li>
                                <li><a href="javascript:;" rel="4">1001~10000</a></li>
                                <li><a href="javascript:;" rel="5">10001~100000+</a></li>
                                <li class="clear" style="height:60px">
                                    <a href="javascript:;">筛选金额</a><br />
                                    <input type="text" class="input" name="startoutstanding" placeholder="最小" size="3"/>-
                                    <input type="text" class="input" name="endoutstanding" placeholder="最大" size="3"/></li>
                            </ul>
                        </span>
                    </th>
                <?php } ?>
                <th>
                    <span class="dropdown clear">
                        <a href="javascript:;" title="" class="btn btn_n_s">
                            <span><em>备注</em><b class="arrow"></b></span>
                        </a>
                        <ul class="filter memofilter clear" field="memo">
                            <li><a href="javascript:;" rel="0" style="margin-left:5px;">全部</a></li>
                            <li class="clear" style="height:40px">
                                <input type="text" class="input" name="memo" placeholder="请输入关键字" size="15"/>
                            </li>
                        </ul>
                    </span>
                </th>
                <th width="100">操作</th>
            </tr>
        </form>
        </thead>
        <tbody>
            <?php include VIEWPATH . 'bill/ajax.php'; ?>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    KS.common.load('bill.index');
    KS.bill.params(<?= json_encode($_GET) ?>);
</script>